﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="OnlineRequestSlip.aspx.cs" Culture="en-GB" Inherits="Main_Inventory_OnlineRequestSlip" %>

<%@ Register Src="~/User Controls/PageHeading.ascx" TagName="heading" TagPrefix="acc" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="Ajax" %>
<%--<%@ Register Assembly="CalendarExtenderPlus" Namespace="AjaxControlToolkitPlus" TagPrefix="advancedCalender" %>--%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script src="../../JavaScript/Commons.js" type="text/javascript"></script>
    <link href="../../Styles/accounts.css" rel="stylesheet" type="text/css" />
    <title></title>
    <style type="text/css">
        .AutoExtender
        {
            margin: 0px;
            background-color: White;
            color: windowtext;
            border: 1px solid #006699;
            line-height: 18px;
            padding: 8px;
            border-width: 1px;
            border-style: solid;
            cursor: 'default';
            height: auto;
            min-height: 10px;
            font-family: Verdana, Helvetica, Sans-Serif;
            font-size: .8em;
            font-weight: normal;
            text-align: left;
            list-style-type: none;
        }
        .AutoExtenderList
        {
            border-bottom: solid 1px #006699;
            color: Maroon;
            padding: 1px;
        }
        .AutoExtenderHighlight
        {
            color: White;
            background-color: #006699;
            padding: 1px;
        }
        #Background
        {
            position: fixed;
            top: 0px;
            bottom: 0px;
            left: 0px;
            right: 0px;
            background-color: #E8EAEC;
            opacity: 0.5;
        }
        #Progress
        {
            position: fixed;
            top: 45%;
            margin-left: 350px;
            width: 300px;
            height: 50px;
            text-align: center;
        }
    </style>
    <script type="text/javascript">       
        function validitemcode() {
            var count = document.getElementById("idvalue").value;
            for (var i = 1; i <= count; i++) {
                var ItemCode = document.getElementById("txtitemcode" + i).value
                if (ItemCode == '')// || Qty != '' || pecode != '' || ro != ''|| customer != 0 || projectname != 0) 
                {
                    alert("Enter Valid Item Code For [" + i + "] Row.");
                    document.getElementById("txtitemcode" + i).focus();
                    return false;
                }
            }
        }
        function validPECode() {
            var count = document.getElementById("idvalue").value;
            for (var i = 1; i <= count; i++) {
                var ItemCode = document.getElementById("txtpecode" + i).value
                if (ItemCode == '')// || Qty != '' || pecode != '' || ro != ''|| customer != 0 || projectname != 0) 
                {
                    alert("Enter Valid PECode For [" + i + "] Row.");
                    document.getElementById("txtpecode" + i).focus();
                    return false;
                }
            }
        }
        function rowEmpty() {
            var count = document.getElementById("idvalue").value;
            for (var i = 1; i <= count; i++) {
                var ItemCode = document.getElementById("txtitemcode" + i).value;
                var Qty = document.getElementById("txtqty" + i).value;
                var pecode = document.getElementById("txtpecode" + i).value;
                var ro = document.getElementById("txtro" + i).value;
                var customer = document.getElementById("ddlcustomer" + i).value;
                var projectname = document.getElementById("ddlprojectname" + i).value;
                if (i == 1) {
                    //                    if (ItemCode == '' || Qty == '' || pecode == '' || ro == '' || customer == 0 || projectname == 0) {
                    //                        alert("Enter Request Slip Details.");
                    //                        return false;
                    //                    }
                    if (ItemCode != '' || Qty != '' || pecode != '' || ro != '' || customer != 0 || projectname != 0) {
                        //CheckRowForOnlineRequestSlip();
                        document.getElementById("txtitemcode" + i).value = '';
                        document.getElementById("txtqty" + i).value = '';
                        document.getElementById("txtpecode" + i).value = '';
                        document.getElementById("txtro" + i).value = '';
                        document.getElementById("txtitemdesc" + i).value = ''
                        document.getElementById("txtproductmodel" + i).value = ''
                        document.getElementById("txtproductdesc" + i).value = ''
                        document.getElementById("ddlcustomer" + i).value = 0;
                        document.getElementById("ddlprojectname" + i).value = 0;
                        document.getElementById("hidTotalqty" + i).innerHTML = 0;
                        //document.getElementById("hidTotalReceiveId" + i).value=0;
                    }
                }
                else {
                    if (ItemCode != '' || Qty != '' || pecode != '' || ro != '' || customer != 0 || projectname != 0) {
                        //CheckRowForOnlineRequestSlip();
                        document.getElementById("txtitemcode" + i).value = '';
                        document.getElementById("txtqty" + i).value = '';
                        document.getElementById("txtpecode" + i).value = '';
                        document.getElementById("txtro" + i).value = '';
                        document.getElementById("txtitemdesc" + i).value = ''
                        document.getElementById("txtproductmodel" + i).value = ''
                        document.getElementById("txtproductdesc" + i).value = ''
                        document.getElementById("ddlcustomer" + i).value = 0;
                        document.getElementById("ddlprojectname" + i).value = 0;
                        document.getElementById("hidTotalqty" + i).innerHTML = 0;
                        //document.getElementById("hidTotalReceiveId" + i).value=0;
                    }
                }
            }
            alert("Your Item(s) Request Is Proceeded.... With Slip No: " + document.getElementById("txtslipno").value);
        }
        function isNumberKey(control_id, evt) {
            var charCode = (evt.which) ? evt.which : event.keyCode
            if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 45 || charCode > 47))
                return false;

            if (charCode == 46) {
                var dotcount = document.getElementById(control_id).value.split('.').length - 1;
                if (dotcount >= 1) {
                    return false;
                }
            }
            return true;
        }

        function isNumber(evt) {
            var charCode = (evt.which)
            //alert(charCode); 
            if (charCode == 46 || charCode == 47 || charCode == 44 || charCode == 59) {//&& charCode > 31 && (charCode < 48 || charCode > 57)) {
                return false;
            }
            if (charCode > 65 && charCode < 91) {
                return false;
            }
            if (charCode > 95 && charCode < 121) {
                return false;
            }
            return true;
        }

        function CatchTab(myfield, e) {//disable keydown event of textbox not TAB key
            var keycode;
            if (window.event) {
                keycode = window.event.keyCode;
            }
            else if (e) {
                keycode = e.which;
            }
            else {
                return true;
            }

            if (keycode == 9) {
                // if is the tab key
                return true;
            }
            else {
                return false;
            }
        }     
    </script>   
    <script type="text/javascript">
        function divExpandCollapse(divname) {
            var div = document.getElementById(divname);
            var img = document.getElementById('img' + divname);
            if (div.style.display == "none") {
                div.style.display = "inline";
                img.src = "../../Menu/images/minus.gif";
            }
            else {
                div.style.display = "none";
                img.src = "../../Menu/images/plus.gif";
            }
        }
    </script>
</head>
<body oncontextmenu="return false;">
    <form id="form1" runat="server">
    <asp:ScriptManager ID="scriptmgr" EnablePageMethods="true" EnablePartialRendering="true"
        runat="server">
    </asp:ScriptManager>
    <asp:Panel ID="pnlonlinedetail" runat="server">
        <acc:heading ID="header1" runat="server" HeadingText="Online Request Slip" />
        <div align="center">
            <asp:Label ID="lblmsg" runat="server"></asp:Label>
        </div>
        <asp:UpdateProgress DynamicLayout="false" AssociatedUpdatePanelID="UpdatePanel1" ID="UpdProgress" runat="server">
            <ProgressTemplate>
                <div id="Background" runat="server">
                </div>
                <div align="center" id="Progress">
                    <img src="../../Images/ajax-loader.gif" alt="progessbar" />
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
        <div align="center">
            <asp:UpdatePanel ID="updatepanel2" runat="server">
                <ContentTemplate>
                    <table class="tablecontent" width="90%">
                        <tr>
                            <td class="headtd" colspan="8">
                                Registration Slip
                            </td>
                        </tr>
                        <tr>
                            <td style="padding: 8px;">
                                &nbsp;
                            </td>
                            <td>
                                Request Date<span style="color: Red;">*</span>
                            </td>
                            <td style="padding: 8px;">
                                <asp:TextBox ID="txtreqdate" runat="server" CssClass="input" ForeColor="Black" TabIndex="1"
                                    onkeydown="return CatchTab(this.id,event)" Style="background-color: #C8D0D4;"></asp:TextBox>
                                <asp:ImageButton ID="btnDate" runat="server" ImageUrl="~/Images/calendar.gif" />
                                <Ajax:CalendarExtender ID="Calform" runat="server" PopupButtonID="btnDate" Format="dd/MM/yyyy"
                                    TargetControlID="txtreqdate">
                                </Ajax:CalendarExtender>
                            </td>
                            <td>
                                Requester Name
                            </td>
                            <td>
                                <asp:TextBox ID="txtusername" runat="server" CssClass="input" Enabled="false" ForeColor="Black"
                                    TabIndex="3"></asp:TextBox>
                                <asp:HiddenField ID="hidemailId" runat="server" />
                            </td>
                            <td>
                                Remarks
                            </td>
                            <td>
                                <%--<asp:TextBox ID="txtslipno" runat="server" CssClass="input" TabIndex="2" Enabled="false" ForeColor="Black"></asp:TextBox>--%>
                                <asp:HiddenField ID="txtslipno" runat="server" />
                                <asp:TextBox ID="txtremarks" runat="server" Width="200px" CssClass="inputnumber"
                                    Style="text-align: left;" TabIndex="4"></asp:TextBox>
                            </td>
                            <td>
                            </td>
                        </tr>
                    </table>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
        <asp:UpdatePanel ID="updatepanel" runat="server">
            <ContentTemplate>
                <div align="center" style="margin-top: 20px;">
                    <asp:Label ID="lblStatus" runat="server"></asp:Label>
                    <div>
                        <table class="tablecontent" width="99%">
                            <tr>
                                <td>
                                    <asp:Button ID="btnAddNew" runat="server" Text="Add New" Width="90px" CssClass="button1"
                                        OnClick="btnAddNew_Click" />
                                </td>
                                <td align="right">
                                    Total Row(s):<asp:Label ID="lblrowno" runat="server" Text="3"></asp:Label>&nbsp;
                                </td>
                            </tr>
                        </table>
                        <table cellpadding="2" cellspacing="0" style="border: 1px solid #818181;" width="99%">
                            <tr style="color: Black; font-size: 11px; font-family: Verdana; font-weight: bold;">
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 12%;">
                                    Item Code<span class="required">*</span>
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 12%;">
                                    Item Desc
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 8%;">
                                    Localtion Id
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 8%;">
                                    Bin No
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 4%;">
                                    Avl Qty
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 4%;">
                                    Req Qty<span class="required">*</span>
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 8%;">
                                    <asp:Label ID="Label1" runat="server" Text="PE Code" ToolTip="Pre Engineering Code."
                                        Width="96%"></asp:Label>
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 8%;">
                                    Prod Desc
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 8%;">
                                    Prod Model
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 8%;">
                                    <asp:Label ID="lblro" runat="server" Text="RO#  *" ToolTip="Repair Order No." Width="96%"></asp:Label>
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 8%;">
                                    Customer<span class="required">*</span>
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 8%;">
                                    Project Name<span class="required">*</span>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div style="overflow: auto; border: 1px solid #818181; height: 260px; width: 99%;">
                        <asp:HiddenField ID="idvalue" runat="server" Value="3" />
                        <table id="tblOnlineRequestSlip" runat="server" cellpadding="2" cellspacing="0">
                            <tr>
                                <td style="width: 12%;">
                                    <asp:TextBox ID="txtitemcode1" TabIndex="5" runat="server" CssClass="input" AutoPostBack="true"
                                        OnTextChanged="txtitemcode_TextChanged" Width="96%"></asp:TextBox>
                                    <Ajax:AutoCompleteExtender ID="ExtenderitemCode1" runat="server" ServiceMethod="GetItemCode"
                                        MinimumPrefixLength="1" CompletionInterval="0" EnableCaching="true" FirstRowSelected="false"
                                        OnClientItemSelected="duplicaterow" TargetControlID="txtitemcode1" CompletionListCssClass="AutoExtender"
                                        CompletionListItemCssClass="AutoExtenderList" CompletionListHighlightedItemCssClass="AutoExtenderHighlight"
                                        ShowOnlyCurrentWordInCompletionListItem="true" DelimiterCharacters=";," CompletionSetCount="20">
                                    </Ajax:AutoCompleteExtender>
                                    <script type="text/javascript">
                                        function removetext(id) {                                            
                                            document.getElementById("txtitemcode" + id).value = "";
                                            alert("Enter the Valid Item Name/Item Code.");
                                            document.getElementById("txtitemcode" + id).focus();
                                        }
                                        function duplicaterow(source, eventArgs) {
                                            try {                                                
                                                var count = 1;
                                                var rowcount = document.getElementById("idvalue").value;
                                                var valuetocheck = eventArgs.get_text();
                                                for (var i = 1; i <= rowcount; i++) {
                                                    if (document.getElementById("txtitemcode" + i).value != '') {
                                                        if (valuetocheck == document.getElementById("txtitemcode" + i).value) {
                                                            count++;
                                                            if (count > 2) {
                                                                alert("Duplicate Item Name will not allowed.");
                                                                document.getElementById("txtitemcode" + i).value = '';
                                                                document.getElementById("txtitemcode" + i).focus();
                                                                __doPostBack("txtitemcode" + i, "");                                                                
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            catch (error) {

                                            }
                                        }                                            
                                    </script>
                                </td>
                                <td style="width: 12%;">
                                    <asp:TextBox ID="txtitemdesc1" TabIndex="6" runat="server" Enabled="false" ForeColor="Black"
                                        Style="border: 1px solid gray;" Width="96%"></asp:TextBox>
                                </td>
                                <td style="width: 8%;">
                                    <asp:TextBox ID="txtlocaltionId1" TabIndex="6" runat="server" Enabled="false" ForeColor="Black"
                                        Style="border: 1px solid gray;" Width="96%"></asp:TextBox>
                                </td>
                                <td style="width: 8%;">
                                    <asp:TextBox ID="txtbinNo1" TabIndex="6" runat="server" Enabled="false" ForeColor="Black"
                                        Style="border: 1px solid gray;" Width="96%"></asp:TextBox>
                                </td>
                                <td style="width: 4%;">
                                    <%--<asp:HiddenField ID="hidTotalqty1" runat="server" />--%>
                                    <asp:Label ID="hidTotalqty1" TabIndex="7" runat="server" Text="0" CssClass="inputnumber"
                                        Width="99%" Height="18px" Style="background-color: LightGray;"></asp:Label>
                                    <asp:HiddenField ID="hidTotalReceiveId1" runat="server" />
                                </td>
                                <td style="width: 4%;">
                                    <asp:TextBox ID="txtqty1" TabIndex="8" runat="server" MaxLength="8" CssClass="inputnumber" onblur="return checkqty(this.id);"
                                        onKeyPress="return isNumber(event);" Width="96%"></asp:TextBox>
                                    <script type="text/javascript">
                                        function checkqty(id) 
                                        {
                                            var Row = id.replace(/[^\d.]/g, '');                                             
                                            var qty = document.getElementById(id).value;
                                            var hidqty = document.getElementById("hidTotalqty" + Row).innerHTML;
                                            if (parseInt(qty) > parseInt(hidqty)) 
                                            {
                                                alert("Available Quantity for Row["+Row+"] is:- " + parseFloat(hidqty).toFixed(0));                                                    
                                            }                                            
                                        }
                                    </script>
                                </td>
                                <td style="width: 8%;">
                                    <asp:TextBox ID="txtpecode1" TabIndex="9" CssClass="input" runat="server" AutoPostBack="true"
                                        OnTextChanged="txtpecode_TextChanged" Width="96%"></asp:TextBox>
                                    <Ajax:AutoCompleteExtender ID="ExternderpeCode1" runat="server" ServiceMethod="GetPeCode"
                                        MinimumPrefixLength="1" CompletionInterval="0" EnableCaching="true" FirstRowSelected="false"
                                        TargetControlID="txtpecode1" CompletionListCssClass="AutoExtender" CompletionListItemCssClass="AutoExtenderList"
                                        CompletionListHighlightedItemCssClass="AutoExtenderHighlight" ShowOnlyCurrentWordInCompletionListItem="true"
                                        DelimiterCharacters=";," CompletionSetCount="20">
                                    </Ajax:AutoCompleteExtender>
                                    <script type="text/javascript">
                                        function removetext(id) {
                                            //alert(id);
                                            document.getElementById("txtpecode" + id).value = "";
                                            alert("Enter the Valid Pe Code.");
                                            document.getElementById("txtpecode" + id).focus();
                                        }
                                        function duplicaterowPe(source, eventArgs) {
                                            try {
                                                //alert(eventArgs.get_text());                                                                                                                                                                                                        
                                                //str1 = row.replace(/[^\d.]/g, '');
                                                var count = 1;
                                                var rowcount = document.getElementById("idvalue").value;
                                                var valuetocheck = eventArgs.get_text();
                                                for (var i = 1; i <= rowcount; i++) {
                                                    if (document.getElementById("txtpecode" + i).value != '') {
                                                        if (valuetocheck == document.getElementById("txtpecode" + i).value) {
                                                            count++;
                                                            if (count > 2) {
                                                                alert("Duplicate Pe Code will not allowed.");
                                                                document.getElementById("txtpecode" + i).value = '';
                                                                document.getElementById("txtpecode" + i).focus();
                                                                __doPostBack("txtpecode" + i, "");
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            catch (error) {
                                            }
                                        }                                            
                                    </script>
                                </td>
                                <td style="width: 8%;">
                                    <asp:TextBox ID="txtproductdesc1" TabIndex="10" Width="96%" runat="server" Enabled="false"
                                        ForeColor="Black" Style="border: 1px solid gray;"></asp:TextBox>
                                </td>
                                <td style="width: 8%;">
                                    <asp:TextBox ID="txtproductmodel1" TabIndex="11" runat="server" Width="96%" Enabled="false"
                                        ForeColor="Black" Style="border: 1px solid gray;"></asp:TextBox>
                                </td>
                                <td style="width: 8%;">
                                    <asp:TextBox ID="txtro1" runat="server" TabIndex="12" Width="96%" CssClass="input"></asp:TextBox>
                                </td>
                                <td style="width: 8%;">
                                    <asp:DropDownList ID="ddlcustomer1" TabIndex="13" runat="server" AutoPostBack="true"
                                        CssClass="dropdown" Width="98%">
                                    </asp:DropDownList>
                                </td>
                                <td style="width: 8%;">
                                    <asp:DropDownList ID="ddlprojectname1" Width="98%" TabIndex="14" runat="server" AutoPostBack="true"
                                        CssClass="dropdown">
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 12%;">
                                    <asp:TextBox ID="txtitemcode2" runat="server" TabIndex="15" CssClass="input" Width="96%"
                                        AutoPostBack="true" OnTextChanged="txtitemcode_TextChanged"></asp:TextBox>
                                    <Ajax:AutoCompleteExtender ID="ExtenderitemCode2" runat="server" ServiceMethod="GetItemCode"
                                        MinimumPrefixLength="1" CompletionInterval="0" EnableCaching="true" FirstRowSelected="false"
                                        OnClientItemSelected="duplicaterow" TargetControlID="txtitemcode2" CompletionListCssClass="AutoExtender"
                                        CompletionListItemCssClass="AutoExtenderList" CompletionListHighlightedItemCssClass="AutoExtenderHighlight"
                                        ShowOnlyCurrentWordInCompletionListItem="true" DelimiterCharacters=";," CompletionSetCount="20">
                                    </Ajax:AutoCompleteExtender>
                                </td>
                                <td style="width: 12%;">
                                    <asp:TextBox ID="txtitemdesc2" runat="server" TabIndex="16" Width="96%" Enabled="false"
                                        ForeColor="Black" Style="border: 1px solid gray;"></asp:TextBox>
                                </td>
                                <td style="width: 8%;">
                                    <asp:TextBox ID="txtlocaltionId2" TabIndex="6" runat="server" Enabled="false" ForeColor="Black"
                                        Style="border: 1px solid gray;" Width="96%"></asp:TextBox>
                                </td>
                                <td style="width: 8%;">
                                    <asp:TextBox ID="txtbinNo2" TabIndex="6" runat="server" Enabled="false" ForeColor="Black"
                                        Style="border: 1px solid gray;" Width="96%"></asp:TextBox>
                                </td>
                                <td style="width: 4%;">
                                    <asp:Label ID="hidTotalqty2" runat="server" Text="0" TabIndex="17" CssClass="inputnumber"
                                        Width="99%" Height="18px" Style="background-color: LightGray;"></asp:Label>
                                    <%--<asp:HiddenField ID="HiddenField1" runat="server" />--%>
                                    <asp:HiddenField ID="hidTotalReceiveId2" runat="server" />
                                </td>
                                <td style="width: 4%;">
                                    <asp:TextBox ID="txtqty2" runat="server" Width="96%" CssClass="inputnumber" MaxLength="8" TabIndex="18"
                                        onblur="return checkqty(this.id);" onKeyPress="return isNumber(event);"></asp:TextBox>
                                </td>
                                <td style="width: 8%;">
                                    <asp:TextBox ID="txtpecode2" runat="server" CssClass="input" Width="96%" TabIndex="19"
                                        AutoPostBack="true" OnTextChanged="txtpecode_TextChanged"></asp:TextBox>
                                    <Ajax:AutoCompleteExtender ID="ExternderpeCode2" runat="server" ServiceMethod="GetPeCode"
                                        MinimumPrefixLength="1" CompletionInterval="0" EnableCaching="true" FirstRowSelected="false"
                                        TargetControlID="txtpecode2" CompletionListCssClass="AutoExtender" CompletionListItemCssClass="AutoExtenderList"
                                        CompletionListHighlightedItemCssClass="AutoExtenderHighlight" ShowOnlyCurrentWordInCompletionListItem="true"
                                        DelimiterCharacters=";," CompletionSetCount="20">
                                    </Ajax:AutoCompleteExtender>
                                </td>
                                <td style="width: 8%;">
                                    <asp:TextBox ID="txtproductdesc2" runat="server" TabIndex="20" Width="96%" Enabled="false"
                                        ForeColor="Black" Style="border: 1px solid gray;"></asp:TextBox>
                                </td>
                                <td style="width: 8%;">
                                    <asp:TextBox ID="txtproductmodel2" TabIndex="21" runat="server" Width="96%" Enabled="false"
                                        ForeColor="Black" Style="border: 1px solid gray;"></asp:TextBox>
                                </td>
                                <td style="width: 8%;">
                                    <asp:TextBox ID="txtro2" CssClass="input" TabIndex="22" runat="server" Width="96%"></asp:TextBox>
                                </td>
                                <td style="width: 8%;">
                                    <asp:DropDownList ID="ddlcustomer2" TabIndex="23" runat="server" Width="98%" AutoPostBack="true"
                                        CssClass="dropdown">
                                    </asp:DropDownList>
                                </td>
                                <td style="width: 8%;">
                                    <asp:DropDownList ID="ddlprojectname2" TabIndex="24" runat="server" Width="98%" AutoPostBack="true"
                                        CssClass="dropdown">
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 12%;">
                                    <asp:TextBox ID="txtitemcode3" TabIndex="25" CssClass="input" runat="server" Width="96%"
                                        AutoPostBack="true" OnTextChanged="txtitemcode_TextChanged"></asp:TextBox>
                                    <Ajax:AutoCompleteExtender ID="ExtenderitemCode3" runat="server" ServiceMethod="GetItemCode"
                                        MinimumPrefixLength="1" CompletionInterval="0" EnableCaching="true" FirstRowSelected="false"
                                        OnClientItemSelected="duplicaterow" TargetControlID="txtitemcode3" CompletionListCssClass="AutoExtender"
                                        CompletionListItemCssClass="AutoExtenderList" CompletionListHighlightedItemCssClass="AutoExtenderHighlight"
                                        ShowOnlyCurrentWordInCompletionListItem="true" DelimiterCharacters=";," CompletionSetCount="20">
                                    </Ajax:AutoCompleteExtender>
                                </td>
                                <td style="width: 12%;">
                                    <asp:TextBox ID="txtitemdesc3" TabIndex="26" runat="server" Width="96%" Enabled="false"
                                        ForeColor="Black" Style="border: 1px solid gray;"></asp:TextBox>
                                </td>
                                <td style="width: 8%;">
                                    <asp:TextBox ID="txtlocaltionId3" TabIndex="6" runat="server" Enabled="false" ForeColor="Black"
                                        Style="border: 1px solid gray;" Width="96%"></asp:TextBox>
                                </td>
                                <td style="width: 8%;">
                                    <asp:TextBox ID="txtbinNo3" TabIndex="6" runat="server" Enabled="false" ForeColor="Black"
                                        Style="border: 1px solid gray;" Width="96%"></asp:TextBox>
                                </td>
                                <td style="width: 4%;">
                                    <%--<asp:HiddenField ID="hidTotalqty3" runat="server" />--%>
                                    <asp:Label ID="hidTotalqty3" Height="18px" runat="server" TabIndex="27" Text="0"
                                        CssClass="inputnumber" Width="99%" Style="background-color: LightGray;"></asp:Label>
                                    <asp:HiddenField ID="hidTotalReceiveId3" runat="server" />
                                </td>
                                <td style="width: 4%;">
                                    <asp:TextBox ID="txtqty3" runat="server" CssClass="inputnumber" MaxLength="8" TabIndex="28" Width="96%"
                                        onblur="return checkqty(this.id);" onKeyPress="return isNumber(event);"></asp:TextBox>
                                </td>
                                <td style="width: 8%;">
                                    <asp:TextBox ID="txtpecode3" TabIndex="29" CssClass="input" runat="server" Width="96%"
                                        AutoPostBack="true" OnTextChanged="txtpecode_TextChanged"></asp:TextBox>
                                    <Ajax:AutoCompleteExtender ID="ExternderpeCode3" runat="server" ServiceMethod="GetPeCode"
                                        MinimumPrefixLength="1" CompletionInterval="0" EnableCaching="true" FirstRowSelected="false"
                                        TargetControlID="txtpecode3" CompletionListCssClass="AutoExtender" CompletionListItemCssClass="AutoExtenderList"
                                        CompletionListHighlightedItemCssClass="AutoExtenderHighlight" ShowOnlyCurrentWordInCompletionListItem="true"
                                        DelimiterCharacters=";," CompletionSetCount="20">
                                    </Ajax:AutoCompleteExtender>
                                </td>
                                <td style="width: 8%;">
                                    <asp:TextBox ID="txtproductdesc3" TabIndex="30" runat="server" Width="96%" Enabled="false"
                                        ForeColor="Black" Style="border: 1px solid gray;"> </asp:TextBox>
                                </td>
                                <td style="width: 8%;">
                                    <asp:TextBox ID="txtproductmodel3" TabIndex="31" runat="server" Width="96%" Enabled="false"
                                        ForeColor="Black" Style="border: 1px solid gray;"></asp:TextBox>
                                </td>
                                <td style="width: 8%;">
                                    <asp:TextBox ID="txtro3" CssClass="input" runat="server" TabIndex="32" Width="96%"></asp:TextBox>
                                </td>
                                <td style="width: 8%;">
                                    <asp:DropDownList ID="ddlcustomer3" TabIndex="33" runat="server" Width="98%" AutoPostBack="true"
                                        CssClass="dropdown">
                                    </asp:DropDownList>
                                </td>
                                <td style="width: 8%;">
                                    <asp:DropDownList ID="ddlprojectname3" TabIndex="34" runat="server" Width="98%" AutoPostBack="true"
                                        CssClass="dropdown">
                                    </asp:DropDownList>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <table align="center">
                    <tr>
                        <td>
                            <asp:Button ID="btnSave" runat="server" Text="Save" OnClientClick="return CheckValidationVisible();validate();"
                                Width="90px" CssClass="button1" OnClick="btnSave_Click" />
                            <script type="text/javascript">
                                function CheckValidationVisible() {
                                    document.getElementById("btnSave").style.visibility = "hidden";
                                    return true;
                                }
                                function validate() 
                                {                     
                                    if (validation() == true && ValidateItems1() == true) 
                                    {
                                        //                              
                                        return true;
                                    }
                                    else 
                                    {
                                        return false;
                                    }
                                }

                                function validation() {
                                    if (document.getElementById("txtreqdate").value == '') {
                                        alert("Enter Request Date.");
                                        document.getElementById("btnDate").focus();
                                        return false;
                                    }                                                                     
                                    else {
                                        return true;
                                    }
                                }
                                function ValidateItems1() {
                                    var Count = document.getElementById("lblrowno").innerHTML;
                                    var set = 0;
                                    for (var i = 1; i <= Count; i++) {
                                        if (document.getElementById("txtitemcode" + i).value == '' && document.getElementById("txtqty" + i).value == '' && document.getElementById("txtpecode" + i).value == '' && document.getElementById("txtro" + i).value == '' && document.getElementById("ddlcustomer" + i).selectedIndex == 0 && document.getElementById("ddlprojectname" + i).selectedIndex == 0) {
                                            set = set + 1;
                                        }
                                        if (set == Count) {
                                            alert('Please Create At least one Item');
                                            document.getElementById("txtitemcode1").focus();
                                            return false;
                                        }
                                    }
                                    if (Count != set) {
                                        for (var i = 1; i <= Count; i++) {
                                            if (document.getElementById("txtitemcode" + i).value != '') {
                                                if (document.getElementById("txtqty" + i).value == '' || document.getElementById("txtqty" + i).value == 0) {
                                                    alert('Please Specify Quantity at Row No ' + ' ' + i);
                                                    document.getElementById("txtqty" + i).focus();
                                                    return false;
                                                }                                                
                                                if (document.getElementById("txtro" + i).value == '' || document.getElementById("txtro" + i).value == 0) {
                                                    alert('Please Specify RO# at Row No ' + ' ' + i);
                                                    document.getElementById("txtro" + i).focus();
                                                    return false;
                                                }
                                                if (document.getElementById("ddlcustomer" + i).selectedIndex == 0) {
                                                    alert('Please Select Customer at Row no ' + '' + i);
                                                    document.getElementById("ddlcustomer" + i).focus();
                                                    return false;
                                                }
                                                if (document.getElementById("ddlprojectname" + i).selectedIndex == 0) {
                                                    alert('Please Select Project at Row no ' + '' + i);
                                                    document.getElementById("ddlprojectname" + i).focus();
                                                    return false;
                                                }
                                            }
                                            else if (document.getElementById("txtqty" + i).value != '') {
                                                if (document.getElementById("txtitemcode" + i).value == '' || document.getElementById("txtitemcode" + i).value == 0) {
                                                    alert('Please Specify Quantity at Row No ' + ' ' + i);
                                                    document.getElementById("txtitemcode" + i).focus();
                                                    return false;
                                                }                                               
                                                if (document.getElementById("txtro" + i).value == '' || document.getElementById("txtro" + i).value == 0) {
                                                    alert('Please Specify RO# at Row No ' + ' ' + i);
                                                    document.getElementById("txtro" + i).focus();
                                                    return false;
                                                }
                                                if (document.getElementById("ddlcustomer" + i).selectedIndex == 0) {
                                                    alert('Please Select Customer at Row no ' + '' + i);
                                                    document.getElementById("ddlcustomer" + i).focus();
                                                    return false;
                                                }
                                                if (document.getElementById("ddlprojectname" + i).selectedIndex == 0) {
                                                    alert('Please Select Project at Row no ' + '' + i);
                                                    document.getElementById("ddlprojectname" + i).focus();
                                                    return false;
                                                }
                                            }                                           
                                            else if (document.getElementById("txtro" + i).value != '') {
                                                if (document.getElementById("txtitemcode" + i).value == '' || document.getElementById("txtitemcode" + i).value == 0) {
                                                    alert('Please Specify Quantity at Row No ' + ' ' + i);
                                                    document.getElementById("txtqty" + i).focus();
                                                    return false;
                                                }
                                                if (document.getElementById("txtqty" + i).value == '' || document.getElementById("txtqty" + i).value == 0) {
                                                    alert('Please Specify Quantity at Row No ' + ' ' + i);
                                                    document.getElementById("txtqty" + i).focus();
                                                    return false;
                                                }                                                
                                                if (document.getElementById("ddlcustomer" + i).selectedIndex == 0) {
                                                    alert('Please Select Customer at Row no ' + '' + i);
                                                    document.getElementById("ddlcustomer" + i).focus();
                                                    return false;
                                                }
                                                if (document.getElementById("ddlprojectname" + i).selectedIndex == 0) {
                                                    alert('Please Select Project at Row no ' + '' + i);
                                                    document.getElementById("ddlprojectname" + i).focus();
                                                    return false;
                                                }
                                            }
                                            else if (document.getElementById("ddlcustomer" + i).selectedIndex != 0) {
                                                if (document.getElementById("txtitemcode" + i).value == '' || document.getElementById("txtitemcode" + i).value == 0) {
                                                    alert('Please Specify Quantity at Row No ' + ' ' + i);
                                                    document.getElementById("txtqty" + i).focus();
                                                    return false;
                                                }
                                                if (document.getElementById("txtqty" + i).value == '' || document.getElementById("txtqty" + i).value == 0) {
                                                    alert('Please Specify Quantity at Row No ' + ' ' + i);
                                                    document.getElementById("txtqty" + i).focus();
                                                    return false;
                                                }
                                                if (document.getElementById("txtro" + i).value == '' || document.getElementById("txtro" + i).value == 0) {
                                                    alert('Please Specify RO# at Row No ' + ' ' + i);
                                                    document.getElementById("txtro" + i).focus();
                                                    return false;
                                                }                                               
                                                if (document.getElementById("ddlprojectname" + i).selectedIndex == 0) {
                                                    alert('Please Select Project at Row no ' + '' + i);
                                                    document.getElementById("ddlprojectname" + i).focus();
                                                    return false;
                                                }
                                            }
                                            else if (document.getElementById("ddlprojectname" + i).selectedIndex != 0) {
                                                if (document.getElementById("txtitemcode" + i).value == '' || document.getElementById("txtitemcode" + i).value == 0) {
                                                    alert('Please Specify Quantity at Row No ' + ' ' + i);
                                                    document.getElementById("txtqty" + i).focus();
                                                    return false;
                                                }
                                                if (document.getElementById("txtqty" + i).value == '' || document.getElementById("txtqty" + i).value == 0) {
                                                    alert('Please Specify Quantity at Row No ' + ' ' + i);
                                                    document.getElementById("txtqty" + i).focus();
                                                    return false;
                                                }
                                                if (document.getElementById("txtro" + i).value == '' || document.getElementById("txtro" + i).value == 0) {
                                                    alert('Please Specify RO# at Row No ' + ' ' + i);
                                                    document.getElementById("txtro" + i).focus();
                                                    return false;
                                                }                                                
                                                if (document.getElementById("ddlcustomer" + i).selectedIndex == 0) {
                                                    alert('Please Select Customer at Row no ' + '' + i);
                                                    document.getElementById("ddlcustomer" + i).focus();
                                                    return false;
                                                }
                                            }
                                        }
                                    }                                      
                                    return true;
                                }                                
                            </script>
                            <asp:Button ID="btnCancel" runat="server" Text="Cancel" Width="90px" CssClass="button1"
                                OnClick="btnCancel_Click" />
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:UpdatePanel>
    </asp:Panel>
    <asp:Panel ID="pnlview" runat="server">
        <acc:heading ID="Heading1" runat="server" HeadingText="Online Request Slip Details" />
        <div align="center">
            <asp:GridView ID="grdonlineregistration" runat="server" CssClass="gridview" AutoGenerateColumns="false"
                RowStyle-CssClass="gridviewitem" AlternatingRowStyle-CssClass="gridview_alternate"
                Width="98%" AllowPaging="True" OnDataBound="grdonlineregistration_DataBound"
                OnPageIndexChanging="grdonlineregistration_PageIndexChanging" PageSize="20" OnRowEditing="grdonlineregistration_RowEditing"
                OnRowDataBound="grdonlineregistration_RowDataBound">
                <Columns>
                    <asp:TemplateField HeaderText="S.No">
                        <ItemTemplate>
                            <%# Container.DataItemIndex+1%>
                            <a href="Javascript:divExpandCollapse('div<%# Eval("SLIPNO") %>');">
                                <img id="imgdiv<%#Eval("SLIPNO") %>" width="9px" border="0" src="../../Menu/images/plus.gif" />
                            </a>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Slip No">
                        <ItemTemplate>
                            <asp:Label ID="lblSlipNo" runat="server" Text='<%#Bind("SLIPNO")%>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField HeaderText="User Name" DataField="REQUESTERNAME" />
                    <asp:BoundField HeaderText="Request Date" DataField="REQDATE" DataFormatString="{0:dd-MMM-yyyy}" />
                    <asp:BoundField HeaderText="Remarks" DataField="REMARKS" NullDisplayText="-" />
                    <asp:TemplateField>
                        <ItemTemplate>
                            <tr>
                                <td colspan="100%">
                                    <div id="div<%# Eval("SLIPNO") %>" style="display: none; position: relative; left: 15px;
                                        overflow: auto">
                                        <asp:GridView ID="gvPORemarksChild" runat="server" CssClass="gridview" AutoGenerateColumns="false"
                                            Width="96%">
                                            <Columns>
                                                <asp:TemplateField HeaderText="S.No">
                                                    <ItemTemplate>
                                                        <%# Container.DataItemIndex+1 %>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:BoundField HeaderText="Item Code" DataField="ITEMCODE" />
                                                <asp:BoundField HeaderText="Item Desc" DataField="ITEMDESC" />
                                                <asp:BoundField HeaderText="Requested Qty" DataField="QTY" ItemStyle-HorizontalAlign="Right" />
                                                <asp:BoundField HeaderText="PE Code" DataField="PECODE" NullDisplayText="-" />
                                                <asp:BoundField HeaderText="Product Desc" DataField="PRODUCTDESC" NullDisplayText="-" />
                                                <asp:BoundField HeaderText="Product Model" DataField="PRODUCTMODEL" NullDisplayText="-" />
                                                <asp:BoundField HeaderText="RO#" DataField="RO" />
                                                <asp:BoundField HeaderText="Customer" DataField="CUSTOMER" />
                                                <asp:BoundField HeaderText="Project Name" DataField="PROJECTNAME" />
                                            </Columns>
                                        </asp:GridView>
                                    </div>
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <%--<asp:BoundField HeaderText="Leased Type" DataField="LeasedType" />--%>
                    <%--<asp:TemplateField HeaderText="Edit">
                        <ItemTemplate>
                            <asp:ImageButton ID="lnkbtnEdit" runat="server" OnClick="lnkbtnEdit_Click" CausesValidation="false"
                                CommandName="Edit" CommandArgument='<%#Bind("ID")%>' ImageUrl="../../Menu/images/Edit_user.png" />
                        </ItemTemplate>
                    </asp:TemplateField>--%>
                </Columns>
            </asp:GridView>
        </div>
    </asp:Panel>
    </form>
</body>
</html>
